package com.dk.config;


import com.dk.entity.DtChat;
import com.dk.mapper.DtChatMapper;
import com.dk.mapper.TestMapper;
import com.dk.pojo.Test;
import com.dk.util.SpringUtils;
import com.netflix.zuul.context.RequestContext;
import io.jsonwebtoken.Claims;

import javax.servlet.http.HttpServletRequest;
import java.util.Date;


public class TestGo {

 /*   public static TestMapper testMapper;

    @Autowired
    public static void setTestMapper(TestMapper testMapper){
        TestGo.testMapper = testMapper;
        //WebSocketServer.testMapper = testMapper;
    }*/


    public String mouthColor;
    public String userId;

    public TestGo(String color,String us) {
       // TestMapper bean = SpringUtils.getBean(TestMapper.class);
        DtChatMapper bean1 = SpringUtils.getBean(DtChatMapper.class);
        mouthColor = color;
        userId = us;
        System.out.println(mouthColor);
        /*Test test = new Test();
        test.setContent(mouthColor);
        test.setUid(10);*/
        DtChat dtChat = new DtChat();
        dtChat.setContent(mouthColor);
        dtChat.setBid(1L);
        dtChat.setUid(1L);
        dtChat.setSid(1L);
        dtChat.setTime(new Date());
        //bean.insert(test);
        bean1.insert(dtChat);
        /*登录态//获取当前线程请求上下文类
        RequestContext currentContext = RequestContext.getCurrentContext();
        //获取request域对象
        HttpServletRequest request = currentContext.getRequest();
        *//** 通过请求头获取token*//*
        String authToken = request.getHeader("authToken");
        Claims claims = jwtUtil.parseJwt(authToken);
        claims.getId();
        claims.getSubject();*/
    }

    public String getUserId() {
        return userId;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    public String getMouthColor() {
        return mouthColor;
    }

    public void setMouthColor(String mouthColor) {
        this.mouthColor = mouthColor;
    }

    public static TestGo build(String color,String us){
        return new TestGo(color,us);
    }


}
